import br.com.nooclix.salon.ui.dto.attendance.AttendanceSheetTO;
import br.com.nooclix.salon.ui.screen.attendancesheet.AttendanceSheetWindow;
import br.com.nooclix.salon.ui.util.ResponseData;
import br.com.nooclix.salon.ui.util.Utilitys;
import br.com.nooclix.salon.ui.util.WindowsMessage;

import mx.rpc.events.ResultEvent;

public function start():void{
	
	listBookingByDaySelected();

}

public function listBookingsByDayResult(event:ResultEvent):void{
	
	var responseData:ResponseData = event.result as ResponseData;
	
	if(responseData.status == ResponseData.ok()){
		gridBooking.dataProvider = responseData.items;
	}else{
		WindowsMessage.alarm(responseData.message);
	}

}

public function listBookingByDaySelected():void{
	var daySelected:Date = fieldDate.selectedDate;
	
	labelTop.text = "Lista de Reservas de: "+Utilitys.formatDate(daySelected) + ", reservas ordenadas por horário!";
	 
	attendanceSheetRemote.listBookingsByDay(daySelected);
	
}

public function showCompleteBooking():void{
	
	var at:AttendanceSheetTO = null;
	at = gridBooking.selectedItem as AttendanceSheetTO;
	
	if(at == null){
		WindowsMessage.alarm("Selecione um cliente na tabela de reservas.");
		return;
	}

	var attendanceSheetWindow:AttendanceSheetWindow = new AttendanceSheetWindow();
	attendanceSheetWindow.openPanel();
	attendanceSheetWindow.renderAttendace(at);
	
}